<?php
class IndexAction extends Action{
	
	function init(){ 
		$usertype=intval(getInf('USER_TYPE'));
		$this->assign('usertype', $usertype);
	}
 
	function cmdIndex(){
		$user=new MyModel();
		$us=$user->all;
		$this->assign("title", SiteConfig::get('site_name'));
		$this->assign('userid', getInf('USER_ID'));
		$this->assign('username', getInf('USER_NAME'));
		$this->assign('logtime', getInf('LOGIN_TIME'));
		$this->assign('u', $us);
		$article=new ArticleModel();
		$this->assign("article",$article->getArticleList(5,null,"desc"));
        $l = new LogModel();
        $this->assign('new_list',$l->getList(null,null,2,null,5));
		$this->view->display("index.htm");
	}
	 
	

	/**
	 * 留言反馈
	 */
	function cmdBug() {
		$mail=isset($_POST['mail'])?$_POST['mail']:null;
		$content=isset($_POST['bugcontent'])?$_POST['bugcontent']:null;
		$ip=getIp();
		$ua=$_SERVER['HTTP_USER_AGENT'];
		$vailcode=isset($_POST['vailcode'])?$_POST['vailcode']:"";
		if (empty($content)){
			$this->Message("反馈内容不能为空","留言提示",PATH."/index.php/index/index?_Sm=".getSid(),3);
		}elseif (!strpos($mail, "@") || !strpos($mail, '.'))
			$this->Message("邮件地址不正确","反馈提示",PATH."/index.php/index/index?_Sm=".getSid(),3);
		elseif (strtoupper($vailcode)!=$_SESSION["bugcode"])
			$this->Message("验证码输入错误!","反馈提示",PATH."/index.php/index/index?_Sm=".getSid(),3);
		else {
			$sts=MailModel::SendMail(SiteConfig::get('bug_email'), '短信猫BUG反馈', "联系邮件:".$mail.":<br />反馈内容:<br />".$content,$mail);
			if ($sts){
				$this->Message("反馈成功！感谢你的支持。",'反馈 提示',PATH."/index.php/index/index?_Sm=".getSid(),3);
			}else{
				$this->Message("抱歉！系统遇到问题。无法完成反馈！",'反馈 提示',PATH."/index.php/index/index?_Sm=".getSid(),3);
			}
		}
		
	}

	function cmdHelp(){
		$this->assign('title', "使用帮助");
		$this->display("help.htm");	
	}
	
	function cmdAbout(){
		$this->assign('title', "关于程序");
		$this->display('about.htm');
	}
}